package com.sc.nft.dao;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.sc.nft.entity.SalvageEventsDetails;
import com.sc.nft.entity.dto.SalvageEventsRewardsDTO;
import com.sc.nft.entity.vo.UserHoldTicketDetailsVO;
import com.sc.nft.entity.vo.salvageEvents.AdminsAlvageEventsCollectionDetailsVO;
import com.sc.nft.entity.vo.salvageEvents.SalvageEventsScreenVO;
import com.sc.nft.mapper.SalvageEventsDetailsMapper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * 分解活动藏品奖励表(sc_salvage_events_details)数据DAO
 *
 * @author Sun
 * @description 由 Mybatisplus Code Generator 创建
 * @since 2023-08-10 13:40:55
 */
@Slf4j
@Repository
public class SalvageEventsDetailsDao extends ServiceImpl<SalvageEventsDetailsMapper, SalvageEventsDetails> {

    public List<AdminsAlvageEventsCollectionDetailsVO> getAdminDetailsBysalvageEventsId(Long salvageEventsId) {
        return baseMapper.getAdminDetailsBysalvageEventsId(salvageEventsId);
    }

    public List<Long> getCollectionIdBySalvageEventsId(Long salvageEventsId) {
        return baseMapper.getCollectionIdBySalvageEventsId(salvageEventsId);
    }

    public List<UserHoldTicketDetailsVO> getCInfoBySalvageEventsId(Long salvageEventsId) {
        return baseMapper.getCInfoBySalvageEventsId(salvageEventsId);
    }

    public List<SalvageEventsDetails> getListByCollectionId(Long salvageEventsId, Long collectionId) {
        LambdaQueryWrapper<SalvageEventsDetails> wrapper = new LambdaQueryWrapper<>();
        wrapper.eq(SalvageEventsDetails::getSalvageEventsId, salvageEventsId);
        wrapper.eq(SalvageEventsDetails::getCollectionId, collectionId);
        return list(wrapper);
    }

    public List<SalvageEventsDetails> getListByCollectionIds(Long salvageEventsId, List<Long> collectionIds) {
        LambdaQueryWrapper<SalvageEventsDetails> wrapper = new LambdaQueryWrapper<>();
        wrapper.eq(SalvageEventsDetails::getSalvageEventsId, salvageEventsId);
        wrapper.in(SalvageEventsDetails::getCollectionId, collectionIds);
        return list(wrapper);
    }

    public List<SalvageEventsRewardsDTO> getFixedPreSalvageReward(Long salvageEventsId, List<Long> collectionIds) {
        return baseMapper.getFixedPreSalvageReward(salvageEventsId, collectionIds);
    }

    public List<Long> getProportionPreSalvageReward(Long salvageEventsId, List<Long> collectionIds) {
        return baseMapper.getProportionPreSalvageReward(salvageEventsId, collectionIds);
    }

    public List<SalvageEventsScreenVO> getSalvageEventsScreen(Long id) {
        return baseMapper.getSalvageEventsScreen(id);
    }

    public List<Long> getCollectionIdBySalvageEventsIdAndCollectionIds(Long salvageEventsId, List<Long> collectionIds) {
        return baseMapper.getCollectionIdBySalvageEventsIdAndCollectionIds(salvageEventsId, collectionIds);
    }

    public Boolean updateSalvageUsableNum(Integer salvageUsableNum, Long id) {
        LambdaUpdateWrapper<SalvageEventsDetails> wrapper = new LambdaUpdateWrapper<>();
        wrapper.set(SalvageEventsDetails::getSalvageUsableNum, salvageUsableNum);
        wrapper.eq(SalvageEventsDetails::getId, id);
        return update(wrapper);
    }

}